{extend name="base" /}
{block name="cont"}
<div class="row">
    <div class="col-xs-12">

        <div class="row">
            <div class="col-xs-12">
                <h3 class="header smaller lighter blue"></h3>
                <div class="table-header">
                    配送员申请列表
                </div>
                <div class="table-responsive">
                    <table id="sample-table-2" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>id</th>
                            <th>电话</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>地址</th>
                            <th>注册时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>

                        <tbody>
                        {foreach $sqs as $k=>$v}
                        <tr>
                            <td>{$v.user_id}</td>
                            <td>{$v.user_phone}</td>
                            <td>{$v.user_name}</td>
                            {if $v.user_sex==1}
                            <td>男</td>
                            {else /}
                            <td>女</td>
                            {/if}
                            <td>{$v.user_address}</td>
                            <td>{:date('Y-m-d H:i:s',$v.user_ctime)}</td>
                            {if $v.sq_status==0 /}
                            <td class="text-info">待审核</td>
                            {elseif $v.sq_status==1 /}
                            <td class="text-success">审核通过</td>
                            {else /}
                            <td class="text-danger">审核失败</td>
                            {/if}
                            <td>
                                {if $v.sq_status==0 /}
                                <button class="btn btn-success btn-sm" onclick="agreeSq({$v.sq_id})">审核通过</button>
                                <button class="btn btn-success btn-sm"onclick="disagreeSq({$v.sq_id})" >审核不通过</button>
                                {else /}
                                    <p class="text-info">已进行审核操作</p>
                                {/if}
                            </td>

                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>


    </div><!-- /.col -->
</div>
<script>
    function agreeSq(sq_id){
        $.ajax({
            url: "{:url('user/agreeSq')}",
            type: "POST",
            data: {
                sq_id:sq_id
            },
            dataType: "json",
            success: function(res){
                console.log(res);
                if(res.status){
                    location.reload();
                }else {
                    alert(res.msg);
                }
            }
        });
    }
    function disagreeSq(sq_id){
        $.ajax({
            url: "{:url('user/disagreeSq')}",
            type: "POST",
            data: {
                sq_id:sq_id
            },
            dataType: "json",
            success: function(res){
                console.log(res);
                if(res.status){
                    location.reload();
                }else {
                    alert(res.msg);
                }
            }
        });
    }
</script>
{/block}